{  Statement: http://acmp.ru/?main=task&id_task=525
   Verdict: Accepted
}
uses
    SysUtils, Math;
 
var
    n,x,kk:int64;
    a:array[0..10] of int64;

function rnk(n:int64):int64;

var
        i,j:longint;
                f:array[-1010..1010,0..10] of int64;
        
begin
fillchar(f,sizeof(f),0);
for i:=0 to kk do
        f[0][i]:=1;
for i:=1 to n do
        for j:=1 to kk do
                                                f[i][j] := f[i - a[j]][j] + f[i][j - 1];
result := f[n][kk];
end;

begin
reset(input, 'input.txt');
rewrite(output, 'output.txt');
read(n);
x := 1;
kk := 0;
while x <= n do begin
    inc(kk);
    a[kk] := x;
    x := x shl 1;
end;
write(rnk(n));
end.
